package StudyCode.summary.mycollection;

import java.util.Arrays;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class DividesUpTheValuesInTheTwoArraysOfIntegersElementWise {
	public static void main(String[] argv) {
		int[] a = new int[]{34, 35, 36, 37, 37, 37, 67, 68, 69};
		int[] b = new int[]{34, 35, 36, 37, 37, 37, 67, 68, 69};
		System.out.println("按元素顺序将两个整数数组中的值相除:");
		System.out.println(Arrays.toString(divideElementwise(a, b)));
	}

	public static double[] divideElementwise(int[] a, int[] b)
			throws ArithmeticException {

		if (a.length != b.length) {
			throw new ArithmeticException();
		} else {
			double[] result = new double[a.length];
			for (int i = 0; i < a.length; i++) {
				result[i] = (double) a[i] / b[i];
			}
			return result;
		}

	}
}
